// Created by WXX on 2021/10/13 14:32
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

/**
 * 执行用时：4 ms, 在所有 C++ 提交中击败了47.20%的用户
 * 内存消耗：7.3 MB, 在所有 C++ 提交中击败了5.80%的用户
 */
class Solution {
public:
    int minCostToMoveChips(vector<int>& position) {
        typedef long long LL;
        LL res = 1e18;
        int n = position.size();
        for (int i = 0; i < n; i++) {
            LL sum = 0;
            for (int j = 0; j < n; j++)
                sum += abs(position[j] - position[i]) % 2;
            res = min(res, sum);
        }
        return res;
    }
};

int main() {

    vector<int> position = {2, 2, 2, 3, 3};
    cout << Solution().minCostToMoveChips(position) << endl;  // 2

    return 0;
}
